package com.linwen.excise.leetcode;

/**
 * @author : linwen
 * @date : 6:25 下午 2020/11/1
 */
public class _70爬楼梯 {
    public static void main(String[] args) {
        int n=10;
        System.out.println(climbStairs(n));

    }

    private static int climbStairs(int n) {
        if(n==0||n==1){
            return 1;
        }
        //return climbStairs(n-2)+climbStairs(n-1);
        int temp=0,previous=1,after=1;
        for(int i=2;i<=n;i++){
            temp = after;
            after = after+previous;
            previous = temp;
        }
        return after;
    }
}
